import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: '',
    power: [],
    userinfo: {}
  },
  getters: {
    token: (state) => state.token,
    power: (state) => state.power,
    userinfo: (state) => state.userinfo,
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token;
    },
    SET_POWER: (state, power) => {
      state.power = power;
    },
    SET_USERINFO: (state, userinfo) => {
      state.userinfo = userinfo;
    },
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState({
      storage: window.localStorage,
    }),
  ],
})
